/**
 * @Description:
 * @author Sun Yan
 * @date $
 */

export var cellSize = [60, 70];
export var pieRadius = ['7%', '10%'];

/**
 * 模拟数据 [ ['2012-11-11', numberValue] ...]
 * @param startTime
 * @param endTime
 * @return {array}
 */
export function getVirtulData(startTime = '2017-02-01', endTime = '2017-03-01') {
    var date = +echarts.number.parseDate(startTime);
    var end = +echarts.number.parseDate(endTime);
    var dayTime = 3600 * 24 * 1000;
    var data = [];
    for (var time = date; time < end; time += dayTime) {
        data.push([
            // new Date(time).Format('yyyy-MM-dd'),
            echarts.format.formatTime('yyyy-MM-dd', time),
            Math.floor(Math.random() * 10000)
        ]);
    }
    return data;
}


 function getChartDate (type) {
     if (type === 'one') {
         return [
             {
                 name: '北里莫', // 。。
                 value: Math.round(Math.random() * 1124),
             },
         ]
     } else {
         return [
             {
                 name: '北里莫',
                 value: Math.round(Math.random() * 24),
                 itemStyle: {
                     color: '#FFAB33'
                 }
             },
             {
                 name: '交换生',
                 value: Math.round(Math.random() * 24),
                 itemStyle: {
                     color: '#61AFFF',
                 },
             },
             {
                 name: '教职工',
                 value: Math.round(Math.random() * 24),
                 itemStyle: {
                     color: '#63DDAF'
                 }
             }
         ]
     }
 }
/**
 * 获取 chart series 数据
 * @param scatterData { array }
 * @param chart {map}
 * @param type {string} one and undefined
 * @return {*}
 */
export function getPieSeries(scatterData, chart, type) {

    return scatterData.map(function (item, index) {
        var center = chart.convertToPixel('calendar', item);
        console.log(center, item)
        return {
            id: index + 'pie',
            type: 'pie',
            center: center,

            // label: {
            //     normal: {
            //         formatter: '{c}',
            //         position: 'inside'
            //     }
            // },

            label: {
                show: false,
                position: 'center'
            },

            radius: pieRadius,

            itemStyle: {
                borderRadius: 2,
                borderColor: type === 'one' ? '' : '#051227',
                borderWidth: 2
            },

            data: getChartDate(type),
        };
    });
}

/**
 * 更新 chart series 数据
 * @param scatterData { array }
 * @param chart {map}
 * @return {*}
 */
export function getPieSeriesUpdate(scatterData, chart) {
    return scatterData.map(function (item, index) {
        var center = chart.convertToPixel('calendar', item);
        return {
            id: index + 'pie',
            center: center
        };
    });
}

